package edu.sctu.practice.class01.wulixia.month09_wlx.assign03.three;

/**
 * Created by wulixia on 2015/11/5.
 * 程序的主方法中使用clone方法完成两个CloneableCircle类对象的深拷贝
 */
public class TestCloneable {

    public static void main(String[] args) {

        CloneableCircle c1 = new CloneableCircle(5);
        CloneableCircle c2 = (CloneableCircle) c1.clone();

        System.out.println("After copying c1 to circl2");

        if (c1 == c2) {
            System.out.println("c1 and c2 reference to the same object");
        } else {
            System.out.println("c1 and c2 don't point to the same object");
        }

        if (c1.equals(c2)) {
            System.out.println("c1 and c2 have the same contents");
        } else {
            System.out.println("c1 and c2 don't have the same contents");
        }

        c1.setRadius(10);
        c1.getCreator().setFirstname("Michael");
        c1.getCreator().setMi("Z");

        System.out.println("\nAfter modifying c1");
        System.out.println("c1 " + c1);
        System.out.println("c2 " + c2);

        if (c1 instanceof Cloneable) {
            System.out.println("A CloneableCircle objec is cloneable");
        } else {
            System.out.println("A CloneableCircle objec is not cloneable");
        }

        Circle c = new Circle();

        if (c instanceof Cloneable) {
            System.out.println("A Circle object is cloneable");
        } else {
            System.out.println("A Circle object is not cloneable");
        }

    }
}

